********************************************************************************
********************************************************************************
***
*** Filename: 	Secession-Votes-1860-1861.do
*** Author: 	David A Bateman
*** Function: 	Reproduces figures in online appendix showing relationship 
***				between enslaved population and votes on secession (whether
***				for delegates or referendum). Data from Chacon and Jensen's
***				The Political and Economic Geography of Southern Secession (2019)
***				or compiled from state histories.
***	Last update: January 1, 2023
***
********************************************************************************
********************************************************************************

cd "..\Deeper Roots"
set more off

import delimited using "Dataverse\Files\secession-votes-1860-1861.csv", clear

label define icpsrstate 40 "Virginia" 41 "Alabama" 44 "Georgia" 45 "Louisiana" 46 "Mississippi" 47 "North Carolina" 54 "Tennessee"
label value icpsrstate icpsrstate 


lpoly persecession perenslaved , ci	///
	graphreg(col(white)) ylab(, nogrid angle(h) labsize(small))	///
	xlab(, angle(h) labsize(small))	xtitle("", size(small))	///
	ytitle("", size(small)) title("Southern States Vote on Secession", col(black) size(small))	///
	lineopts(lcol(black)) msize(vsmall) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(secession, replace) note("")		

levelsof icpsrs, local(state)
foreach x in `state' {
	local t : label (icpsrstate) `x'	
	summ perenslave if icpsrstate==`x', det
	local min = round(r(p5))
	local max = int(r(p95))
	regress persecession perenslaved if icpsrstate==`x'
	margins, at( perenslaved = (`min'(5)`max'))
	marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(10 70)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("", size(small))	///
	ytitle("", size(small))	///
	graphreg(col(white)) title("`t'", size(small) col(black))		///
	legend(off)	///
	name(state`x', replace)	
	
	}

graph combine secession state40 state41 state44 state45 state46 state47 state54, 	///
	cols(2) graphreg(col(white)) imargin(tiny)	///
	l2title("Predicted Secessionist Vote, 1861", size(small))	///
	b2title("Percentage Held in Slavery", size(small))		///
	note("All but Louisiana and Mississippi are significant at p<0.02.", size(vsmall))
graph display Graph, ysize(11) xsize(8.5)

*** Figure A7: "Secession Votes, 1861"
graph export "Dataverse\Figures\Figure-A7.pdf", as(pdf) replace
